<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="estateTag" prefix="estateTag" %>
	<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>欢迎进入后台管理系统</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" href="../resource/css/whole.css"
			type="text/css"></link>
		<link rel="stylesheet" href="../resource/css/memberCenter/infowithoutmenu.css"
			type="text/css"></link>
		<link rel="stylesheet" href="../resource/css/global.css"
			type="text/css"></link>
		<script src="../resource/js/jquery-1.4.2.js"></script>
	</head>
	<body><estateTag:security></estateTag:security>
		<center><jsp:include page="../index/top.jsp"></jsp:include></center>
		<div style="width: 100%; margin-top: 10px;" align="center">
			<input id="menuCls" type="hidden" value="31">
			<table class="layoutTab" style="border: 0px red solid;">
				<tr>
				<!-- 	<td width="20%" align="left" valign="top"><jsp:include
							page="../menu.jsp"></jsp:include></td> -->
					<td valign="top" align="center">
						<div class="position" align="left"><label>您所在的位置：</label>用户管理&nbsp;&nbsp;--&gt;&gt;&nbsp;&nbsp;账户设置&nbsp;&nbsp;--&gt;&gt;&nbsp;&nbsp;新增用户</div>
						<br/>
						<div class="info_top"></div>
						<div class="info_mid" align="center">
							<h3 style="margin: 0; padding-top: 20px; padding-bottom: 20px;">
								新增用户
							</h3>
							<table border="0" style="margin-left: 20px;" cellpadding="0" cellspacing="0" width="760px">
								<tr>
									<td valign="top" align="center">
									<form action="../user/addUser.shtml" method="post" onsubmit="return check()">
										<table id="userinfo" width="750px" border="0" cellpadding="1"
											cellspacing="1">
											<tr>
												<td align="right" width="16%">
													用户名：
												</td>
												<td align="left">
													<div style="float: left"><input type="text" name="user.username" maxlength="10" id="username" onblur="checkUsername(this.value);"/></div> 
										            <div style="float: left"><input style="font-size:10px" type="button" value="检&nbsp;&nbsp;测" onclick="checkUsername();" ></div>
										            <div style="float: left"><font><span id="checkid" style="color:#FF8080;font-size: 9px;">只包含大小写英文、数字和下划线。同时长度在5-15之间</span></font><font><span id="checkid1" style="color:green"></span></font></div>
												</td>
											</tr>
											<tr>
												<td align="right" width="16%">
													密码：
												</td>
												<td align="left">
													<input type="password" name="user.password" id="password1" value="000000" maxlength="10" />(默认6个0)
												</td>
											</tr>
											<tr>
												<td align="right" width="16%">
													确认密码：
												</td>
												<td align="left">
													<input type="password" id="password2" value="000000" maxlength="10" />
												</td>
											</tr>
											<tr>
												<td colspan="2" align="center">
													<input type="hidden" name="user.id" value="${user.id}"/>
													<input type="hidden" name="user.type" value="${user.type}"/>
													<input id="submit" type="submit" 
														value="提交" />&nbsp;&nbsp;&nbsp;&nbsp;
														<input id="" type="button" 
														value="返回" onclick="history.go(-1)" />
												</td>
											</tr>
										</table>
										</form>
									</td>
								</tr>
							</table>
						</div>
						<div class="info_bottom">
							&nbsp;
						</div>
					</td>
				</tr>
			</table>
		</div>
		<center> <iframe src="../index/footer.html" width="970" height="120" frameborder="0" scrolling="no"></iframe> </center></body>
		<script type="text/javascript">
		var basePath = '<%=basePath%>';
		var isLogin = '0';
	$(function(){
	    $("#userinfo td").not($("#filter_ke td")).addClass("info_td1");
		$("#userinfo tr").find("td:even").not($("#filter_ke td")).addClass("title_info2");
		$("#userinfo tr").find("td:odd").not($("#filter_ke td")).css("padding-left","5px");
	});
	function checkUsername(){
      var username=document.getElementById("username");
      if(!checkNull(username)){
        _Alert(username,"请输入用户名");
        $("#username").css('background-color','#FFFFFF');
		// document.getElementById("checkid").innerHTML="";
        return false;
      }else{
         if(!IsCharAndNum(username)){
	          _Alert(username,"输入用户名应为英文字母、数字");
	           return false;
         }else if(username.value.length>=5&&username.value.length<=15){
	         var url = basePath+'user/checkUserNameIsExistMember.shtml?username='+username.value;
			 $.get(url,function(mes){
				if(mes=="0"){
					$("#username").css('background-color','#FF8080');
					document.getElementById("checkid1").innerHTML="";
					document.getElementById("checkid").innerHTML="&nbsp;该用户名已经存在";
	           	    username.focus();
	           	    isLogin=0;
	           	    return false;
				}else{
					$("#username").css('background-color','#FFFFFF');
					document.getElementById("checkid").innerHTML="";
					document.getElementById("checkid1").innerHTML="&nbsp;可以注册";
	           	    isLogin=1;
				}
			})
            }else{
            	_Alert(username,"用户名长度在5-15之间");
            }
         }
     }
     function _Alert(theText,notice){
       alert(notice)
	   theText.focus();
	 }
	 //用户名只包含大小写英文、数字和下划线。同时用户名长度在6-15之间
	function IsCharAndNum(obj){
	/*alert(reg.test(obj.value));
   		var reg=/^[0-9A-Za-z_]{5,15}$/;
	  if(reg.test(obj.value)){
			return true;
	  }else{
			return false;
	  }
	  */
	  return true;
	}
	function checkNull(obj){
	 if(obj.value.trim().length==0)
		 return false;
	 else
		 return true;
	}
	String.prototype.trim = function(){
    	return this.replace(/(^\s*)|(\s*$)/g, "");
	}
	function check(){
		var username=document.getElementById("username");
		var password1=document.getElementById("password1");
		var password2=document.getElementById("password2");
	
	    if(isLogin=="0"){
		 _Alert(username,"请输入用户名!");
		 return false;
	    }
	    
	    if(!checkNull(password1)){
	      _Alert(password1,"请输入用户密码。");
	      return false;
	    }else{
	       if(password1.value.length<6){
		      _Alert(password1,"输入用户密码长度最小为6位。");
		      return false;
	       }
	    }
	
	    if(!checkNull(password2)){
	      _Alert(password2,"请输入确认密码。");
	      return false;
	    }else{
	      if(password1.value!=password2.value){
		      _Alert(password2,"两次密码不一致。");
		      return false;
	       }
    	}
    	if(isLogin=="0")
    	return false;
    return true;
	}
	</script>
</html>